import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const state = {
	loginshow:true,
	//角色身份，admin，teacher等
	role:"",
	//roleinfo是页面级栏目的权限信息
	roleinfo:"",
	//可访问的动态路由表
	dyrouter:"",
	//7张excel表的评价名
	excelname:"",
	
	
}

const mutations = {
	toggleloginshow(state,tog){
		if(tog == "show"){
			state.loginshow = true;
		}else if(tog == "hide"){
			state.loginshow = false;
		}
	},
	
	SAVE_ROLE(state,value){
		state.role = value;
	},
	SET_DYNAMIC_ROUTER(state,value){
		state.dyrouter = value
	},
	SAVE_ROLE_INFO(state,value){
		state.roleinfo = value;
	},
	SAVE_EXCEL_NAME(state,value){
		state.excelname = value;
	},
}
const getters = {
	role: state => state.role,
	dyrouter: state => state.dyrouter,
	roleinfo: state => state.roleinfo,

}
const actions = {
	setdynamicrouter({commit},data){
		return new Promise(resolve => {
			commit('SET_DYNAMIC_ROUTER',data)
			resolve()
		})
	},
	setrole({commit},data){
		return new Promise(resolve => {
			commit('SAVE_ROLE',data)
			resolve()
		})
	},
	setroleinfo({commit},data){
		return new Promise(resolve => {
			commit('SAVE_ROLE_INFO',data)
			resolve()
		})
	},

}

export default new Vuex.Store({
	state,
	mutations,
	getters,
	actions
})
